1. Field of the Invention
The present invention relates to an image-encoding apparatus, an image-encoding method, and a program for encoding moving images that are captured by an imaging unit on the basis of control parameters of the imaging unit.
2. Description of the Related Art
A method is known, in which the amount of code is controlled for each group of pictures (hereinafter referred to as GOP) when captured moving images are encoded. A GOP includes an intra-frame encoded picture (hereinafter referred to as an I picture) within which encoding is performed, an inter-frame encoded picture obtained by forward prediction (hereinafter referred to as a P picture) in which encoding is performed on the basis of the difference between a present picture and a preceding picture, and an inter-frame encoded picture obtained by bidirectional prediction (hereinafter referred to as a B picture) in which encoding is performed on the basis of the difference between a present picture and a preceding picture and the difference between the present picture and an upcoming picture. Generally, in a GOP, the I picture is the leading picture, and the P and B pictures follow the I picture.
From the viewpoint of encoding, the B picture is most efficient, and then the P picture and then the I picture. However, since the B and P pictures are encoded on the basis of differences between frames, the B and P pictures cannot be decoded by themselves. Moreover, when the correlation between frames is high, the B and P pictures are efficient from the viewpoint of encoding. In contrast, when the correlation is low, the B and P pictures are disadvantageously inefficient. Thus, problems exist, such that the amount of code of each of the B and P pictures heavily depends on the structure of moving images and the image quality may be deteriorated in spite of the original intention by excessively increasing a quantization value in order to cause the amount of code to fall within a predetermined range.
A method that is referred to as variable bit rate control is known, in which the amount of code allocated to each GOP is variable and the quantization value is kept constant as much as possible in order to avoid a deterioration in the image quality. However, the total amount of code varies according to time spent for shooting images. Thus, it is difficult to adjust the total amount of code to an expected total amount of code. Another method that is referred to as two-pass encoding is generally known, in which encoding is first performed with the quantization value of an entire moving image being constant in order to keep the total amount of code constant and then encoding is again performed while the target amount of code of each GOP or each picture is changed according to a change in the amount of generated code. However, this method is not effective for a system that requires real-time processing, such as a digital moving image camera. Thus, a method is provided, in which parallel encoding is performed with more than one encoding unit to achieve real-time processing in two-pass encoding. However, a substantial increase in the size of a circuit cannot be avoided.
A video camera apparatus that addresses the problems described above is disclosed in, for example, Japanese Patent Laid-Open No. 2003-219416, in which the state of an imaging unit is monitored on the basis of control parameters of the imaging unit, and a satisfactory image quality can be achieved by increasing the quantization value even without two-pass encoding in a condition (hereinafter referred to as an unsteady condition) in which control operation is performed so that the state of the imaging unit is changed.
In the video camera apparatus disclosed in Japanese Patent Laid-Open No. 2003-219416, the amount of code can be controlled according to the condition of the imaging unit. However, when the imaging unit is in an unsteady condition in which, for example, the imaging unit is performing zoom operation, performing automatic focus operation, operating an automatic iris, or performing automatic white balance adjustment, the difference between a present image and a reference image is inevitably large. That is to say, in the video camera apparatus described above in which the quantization value is manipulated without consideration of the correlation between frames, when the imaging unit is in an unsteady condition, the quantization value must be set to a large value in order to suppress an increase in the amount of code generated by encoding in each picture. As a result, a problem occurs, such that the image quality significantly deteriorates in an unsteady condition.